<template>
  <view>
    <view v-for="(item, index) in listdata" :key="index">
      <view class="info-card horizontal">
        <view class="item-field price-field">
          <text class="label">产品名称:</text>
          <text class="value">{{ item.productName }}</text>
        </view>
        <view class="item-field price-field">
          <text class="label">产品规格:</text>
          <text class="value">{{ item.productStandards }}</text>
        </view>
<!--        <view class="item-field price-field">
          <text class="label">产品批次:</text>
          <text class="value">{{ item.batch }}</text>
        </view> -->
        <view class="item-field price-field">
          <text class="label">单价:</text>
          <text class="value">{{ item.productPrice }}</text>
          <text class="label">总价:</text>
          <text class="value">{{ item.totalPrice }}</text>
          <text class="label">数量:</text>
          <text class="value">{{ item.count }}</text>
        </view>
      </view>
    </view>
    <view class="button-container">
      <button @click="handleConfirm">确定</button>
    </view>
	<view class="item-field price-field">
	</view>
  </view>
</template>

<script>
  import * as SupplierSendOrderApi from '@/api/suppliersendorder/inde.js';  // 随货同行单
  import * as SupplierSendOrderitemApi from '@/api/suppliersendorderitem/index.js';  // 随货同行单
  import * as SecStockrApi from '@/api/secStock/index.js';  // 二级库库存
  import * as secAccountApi from'@/api/secAccount/index.js';  // 二级库台账
  import * as wareApi from '@/api/warehouseoutlist/index.js';   // 出库单
  import * as highValueNvoiceItem from '@/api/highValueNvoiceItem/index.js'
  import * as highValueNvoice from '@/api/highValueNvoice/index.js'
  export default { 
    data(){
      return {
        totalCount: '',
        resultString: '', // 用于保存生成的uuid
        inputValue: '',   // 商品总数
        data: {},         // 传递过来的单品信息
        listdata: [],     // 根据商品部门id查询库存信息 
        upTotalCount: [],
        myObject: {outId: ''}
      };
    },
    onLoad(options){
      const dataStr = options.data;
      // 将 JSON 字符串解析回对象
      this.data = JSON.parse(dataStr); 
      this.getList(); 
     // this.generateString();
    },
    methods:{
      async getList() {
        try {
          console.log('传递的data数据',this.data);
          this.listdata = await highValueNvoiceItem.getHighValueInvoiceItemByQrcodes(this.data.id);
          console.log('查询到的所有单项',this.listdata);
        } finally {
          // 这里可以添加一些清理代码，如果需要的话
        }
      },
	  handleConfirm(){
		  	
		  SecStockrApi.virtualCreate(this.listdata)
		  uni.navigateBack({delta: 2});
	  }
	  
    },
  };
</script>

<style>
  .container {
    padding: 20px;
    background-color: #f5f5f5;
  }

  .info-card {
    background-color: #ffffff;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  .info-card.horizontal {
    display: flex;

    flex-direction: column;
    align-items: flex-start;
  }

  .item-field {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 10px; /* 添加一些间距 */
  }

  .price-field {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-bottom: 10px; /* 添加一些间距 */
  }

  .label {
    font-size: 15px;
    color: #333333;
    margin-bottom: 5px;
  }

  .value {
    font-size: 13px;
    color: #007aff;
  }

  .button-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #ffffff;
    padding: 10px;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
  }
</style>
